package com.tjmc.nsia.core.exception;

import com.tjmc.nsia.core.constant.ErrorCodeEnum;
import lombok.Data;

/**
 * @author Luc
 * @version 1.0
 * @date 2023-04-27 15:09
 */
@Data
public class GlobalException extends RuntimeException {
    private final String code;

    /**
     * 通过状态码和异常信息创建异常对象
     *
     * @param code
     * @param message
     */
    public GlobalException(String code, String message) {
        super(message);
        this.code = code;
    }

    /**
     * 接受枚举类型对象
     *
     * @param errorCodeEnum
     */
    public GlobalException(ErrorCodeEnum errorCodeEnum) {
        super(errorCodeEnum.getMessage());
        this.code = errorCodeEnum.getCode();
    }

}
